package com.xon.lotp.service.Impl;

import com.xon.lotp.mapper.GroupMapper;
import com.xon.lotp.mapper.ProjectMapper;
import com.xon.lotp.pojo.Group;
import com.xon.lotp.pojo.Project;
import com.xon.lotp.service.ProjectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ProjectServiceImpl implements ProjectService {

    @Autowired
    ProjectMapper projectMapper;

    public Project viewProjectInfo(String projectId, String preferredLanguage) {
        Project project;
        project = projectMapper.viewProjectInfoByLanguage(projectId, preferredLanguage);
        if (project.getGroup().getProjectName() == null || project.getGroup().getProjectIntroduction() == null) {
            Group group = projectMapper.viewProjectInfoByLoc(projectId);
            project.setGroup(group);
        }
        return project;
    }

}
